Skip to content

fix: concentration_guard infinite loop, HWM backfill, time stop (#483, #484, #485)#486

Merged
cct08311github merged 2 commits intomainfrom
fix/483-484-485-strategy-bugs
Mar 27, 2026
Merged

fix: concentration_guard infinite loop, HWM backfill, time stop (#483, #484, #485)#486
cct08311github merged 2 commits intomainfrom
fix/483-484-485-strategy-bugs

Conversation

@cct08311github
Copy link
Copy Markdown
Owner

Summary

修復每日策略審核發現的三個 CRITICAL bug:

Changes

檔案 修改
concentration_guard.py dedup 視窗 360s→3600s、含 filled 狀態、每日 sell cap=3
ticker_watcher.py EOD deviation guard、positions sync after sells、time stop
pnl_engine.py entry_trading_day + _backfill_high_water_mark

Test plan

  • pytest tests/ -q → 887 passed, 4 failed (all pre-existing)
  • pytest frontend/backend/tests/ -q → 581 passed, 1 failed (pre-existing)
  • simulation_mode 觀察 3 個交易日確認 concentration sells 不再超量
  • 確認 1303 在下一個交易日觸發時間止損

Fixes #483, Fixes #484, Fixes #485

🤖 Generated with Claude Code

…stop

concentration_guard.py (#483):
- Extend dedup window from 360s to 3600s and include filled orders
- Add daily sell cap of 3 per symbol to prevent infinite loop

ticker_watcher.py (#484, #485):
- Add EOD price deviation guard blocking buys >5% from last close
- Sync positions table after proposal sells
- Add time-based stop loss: held >5d + loss >5% → force sell

pnl_engine.py (#485):
- Include entry_trading_day in sync_positions_table
- Add _backfill_high_water_mark from eod_prices

Fixes #483, Fixes #484, Fixes #485
Branch: fix/483-484-485-strategy-bugs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…er_mark columns and logger

- test_pnl_engine: add ts_submit to orders, entry_trading_day + high_water_mark to positions
- test_position_quarantine: add entry_trading_day + high_water_mark columns, fix positional INSERT
- pnl_engine: add missing logger for _backfill_high_water_mark warning

Fixes #485
Branch: fix/483-484-485-strategy-bugs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cct08311github cct08311github merged commit 0c5dcb2 into main Mar 27, 2026
4 of 5 checks passed
@cct08311github cct08311github deleted the fix/483-484-485-strategy-bugs branch March 27, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant